

#delimit;
clear all;
version 13.1;
pause on;
program drop _all;
capture log close;
set more off;

/*INSERT FOLDER PATH*/
cd /;


	
	use reappearance_data.dta, clear;
	
/*gen groups*/
	egen authorfield=group(srce_pmid lastname initials);
	egen controlauthorfields=count(rtrct) if rtrct==0;
	egen controlauthorsfields2=max(controlauthorfields);
		drop controlauthorfields;
		rename controlauthorsfields2 controlauthorsfields;

/*regs*/
	estimates drop _all;
	
	xtset srce_pmid;
	


reg post_rtrct_dummy rtrct first_auXrtrct /*middle_auXrtrct*/ last_auXrtrct i.pubyear, cluster(srce_pmid);
		summ rtrct if e(sample);
		estadd scalar nbretracted=r(sum);
		summ controlauthorsfields if e(sample);
		estadd scalar nbcontrol=r(max);
		estimates save estimates/ols_auposition_earliestpubFX.ster, replace;

	
/*reg table*/
	set emptycells drop;
	set matsize 1000;
	estimates drop _all;
	
	estimates use  estimates/ols_auposition_earliestpubFX.ster;
	eststo;
	
	

	esttab *, keep(rtrct first_auXrtrct last_auXrtrct) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) scalars("nbretracted Nb. of Retracted Field-Authors" "nbcontrol Nb. of Control Field-Authors" "r2_a Adjusted R-squared")  sfmt(%10.0fc %10.0fc %5.3f) compress  mlabels("(1)") eqlabels(none);
	
	esttab * using tables/ols_authors_reappear.rtf, keep(rtrct first_auXrtrct last_auXrtrct) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) compress scalars("nbretracted Nb. of Retracted Field-Authors" "nbcontrol Nb. of Control Field-Authors" "r2_a Adjusted R-squared") sfmt(%10.0fc %10.0fc %5.3f)  mlabels("(1)") eqlabels(none) replace;

